import { imageModel } from "../api/models";
export default {
  data() {
    return {
      show: false,
      activeImage: {}
    }
  },
  methods: {
    copyImage(image) {
      if (this.loading) return false
      this.show = true 
      this.activeImage = image
    },
    handleReset() {
      this.show = false
    },
    handleSubmit(name) {
      if (this.loading) return;
      this.loading = true
      this.handleReset()
      this.open()
      imageModel.create1({
        image_id: this.activeImage.id,
        image_name: name
      }, (res) => {
        this.loading = false
        if(res.data.instance_id) {
          this.$router.push('/image/create2/' + res.data.instance_id + '/' + this.activeImage.id + '?vnc=' + res.data.vnc + '&name=' + name)
        }
      },err => {
        this.loading = false
        console.log(err)
      })
    },
     open() {
        this.$notify.success({
          title: '制作镜像',
          message: '镜像正在复制中，请您耐心等待^_^',
          showClose: false
        });
      }
  }
}